package com.waypolice.common.utils;

import java.io.BufferedInputStream;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Properties;

/**
 * 读取配置文件信息
 * @author zhangxiaoyang
 *
 */
public class ReadProperties {
	private static Properties pro=new Properties();
	
	/**
	 * 根据文件名获得Properties对象
	 * @param fileName
	 * @return
	 */
	public static Properties getProperties(String fileName){
		Properties prop=new Properties();
		StringBuffer sb  = new StringBuffer();
		sb.append(ReadProperties.class.getResource("/").getPath());
		sb.append("/properties/");
		sb.append(fileName);
		try {
			BufferedInputStream bis=new BufferedInputStream(new FileInputStream(sb.toString()));
			prop.load(new InputStreamReader(bis, "utf-8"));
		} catch (FileNotFoundException e) {
			e.printStackTrace();
		}catch (IOException e) {
			e.printStackTrace();
		}
		return prop;
	}
}
